/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vanScheduling;

import db.VehicleTypeDAO;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author user
 */
@ManagedBean
@SessionScoped
public class VehicleType {

    private int id;
    private String name;
    private int numOfSeats;

    public VehicleType() {
    }

    public VehicleType(int id, String name, int numOfSeats) {
        this.id = id;
        this.name = name;
        this.numOfSeats = numOfSeats;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumOfSeats() {
        return numOfSeats;
    }

    public void setNumOfSeats(int numOfSeats) {
        this.numOfSeats = numOfSeats;
    }
    public String addVehicleType() {
        VehicleTypeDAO.addVehicleType(this);
        return "vehicleTypeList";
    }

    public String deleteVehicleType() {
        if(VehicleTypeDAO.deleteVehicleType(this)) {
            return "vehicleTypeList";
        } else {
            return "vehicleTypeDeleteFailure";
        }
    }

    public List<VehicleType> getVehicleTypes() {
        return VehicleTypeDAO.getVehicleTypes();
    }


    @Override
    public String toString() {
        return this.name;
    }
}
